package oop3;

/**
 * @author oldliu
 * @since 1.0
 */
public class Person {
    private String name;
    private int age;

    public Person() {

    }

    public Person(String name, int age) {
        this.name = name;
        this.setAge(age);
    }

    //添加 getter和setter方法
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }
    //公共方法内调用了私有方法
    public void guonian(){
        increaseAge();
    }
    private void increaseAge(){
        this.age++;
    }
    //限制年龄必须在14到80之间
    public void setAge(int age) {
        if (age < 14 || age > 80) {
            System.out.println("这个年龄" + age + "不合适");
            return;
        }
        this.age = age;
    }

    public void show() {
        System.out.println("这个人叫" + name + "，今年" + age + "岁了");
    }
}
